﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class SelectLevelPanel : MonoSingleton<SelectLevelPanel>
{
    public Button[] buttonList;
    void Awake()
    {
        buttonList = gameObject.GetComponentsInChildren<Button>();

        for (int i = 0; i < buttonList.Length; i++)
        {
            Button button = buttonList[i];
            EventTriggerListener.Get(button.gameObject, i + 1).onClick = delegate (GameObject go, object data)
            {
                Debug.Log(data);
                
                this.Close();
                ShuaiManager.Instance.level = (int)data;
                ShuaiManager.Instance.EnterLevel();
                //LoadingPanel.Instance.Open();
            };
        }
    }

    public void Open()
    {
        this.gameObject.SetActive(true);

        ShuaiManager.Instance.game_state = GameState.Menu;

        ShuaiManager.Instance.MainCamera.gameObject.SetActive(true);
    }

    public void Close()
    {
        this.gameObject.SetActive(false);

        //ShuaiManager.Instance.MainCamera.gameObject.SetActive(false);
    }
}
